***Local Perceptions, Regional Action: Sources of //
***Public Legitimacy of African Regional Organizations' //
***Democracy Mechanisms***
************************************************
**Authors: Michael Yekple & Zlatin Mitkov**


**Set working Directory**
use data_democracy_promotion.dta
ssc install coefplot, replace
ssc install cleanplots, replace	
	

**Figure 1**

reshape long ecowas sadc eac uma other, i(id) j(region)

collapse (mean) dem_promotion_binary, by(region)
// Convert to percentage points for support
gen support_pct = dem_promotion_binary * 100
// Calculate oppose percentage as 100 minus support_pct
gen oppose_pct = 100 - support_pct

//Save the data files.
tempfile orig_data
save orig_data.dta, replace

// Collapse to generate regional support/opposition percentages
collapse (mean) dem_promotion_binary, by(region)
gen support_pct = dem_promotion_binary * 100
gen oppose_pct = 100 - support_pct
save region_data.dta, replace

// Restore original long-format data and compute total percentages
use orig_data.dta, clear
collapse (mean) dem_promotion_binary
gen support_pct = dem_promotion_binary * 100
gen oppose_pct = 100 - support_pct

// Combine regional and total data
use region_data.dta, clear
append using total_data.dta

label define region_lbl 1 "ECOWAS" 2 "SADC" 3 "EAC" 4 "UMA" 5 "Other" 6 "All Countries", modify
label values region region_lbl

//Graph bar chart showing support and opposition by region and total
set scheme cleanplots

**Figure 1 Public Support for Democracy Promotion by Regional Organization
	
graph bar support_pct oppose_pct, over(region, label(angle(45))) ///
    bar(1, fcolor(gs14) lcolor(black) lpattern(solid)) ///
	bar(2, fcolor(gs0)  lcolor(black) lpattern(dash)) ///
    ytitle("Percentage", size(medsmall)) ///
    blabel(bar, format(%4.1f) size(small)) ///
    title("", size(medsmall)) ///
    legend(order(1 "Support" 2 "Oppose") size(small))


***Public Support for Democracy Promotion***
**Table 1**
use data_democracy_promotion.dta, clear

areg dem_promotion ///
			regional_security ///
			democracy_bestmodel ///
			full_economic ///
			education ///
			gender age, absorb(country)
est store m1
			
areg dem_promotion ///
			african_union ///
			democracy_bestmodel ///
			full_economic ///
			education ///
			gender age, absorb(country)
est store m2

outreg2 [m1 m2] using regression_table1.doc, ///
               replace keep(regional_security african_union democracy_bestmodel full_economic education gender age) label dec(3) ///
			   title(Table 1: Public Support for Democracy Promotion) ///
			   addnote("Multivariate Regression OLS Coefficients with Country Fixed Effects")

			   
			  
**Figure 1**

coefplot m1, ///
    drop(_cons) ///
    keep(regional_security ///
			democracy_bestmodel ///
			full_economic ///
			education ///
			gender age) ///
    xline(0, lpattern(dash)) ///
    title(Model 1 Usefulness REC 95% CI) ///
    xlabel() ylabel(, labsize(medium)) ///
    grid(none) name(p1, replace)


coefplot m2, ///
    drop(_cons) ///
    keep(african_union ///
			democracy_bestmodel ///
			full_economic ///
			education ///
			gender age) ///
    xline(0, lpattern(dash)) ///
    title(Model 2 Usefulness of AU 95% CI) ///
    xlabel() ylabel(, labsize(medium)) ///
    grid(none) name(p2, replace)

graph combine p1 p2, rows(2) cols(2) imargin(zero) ///
    title() iscale(.8)
	
	

**Table 2 by Regional Organization**

areg dem_promotion ///
			regional_security ///
			full_economic ///
			democracy_bestmodel ///
			education ///
			gender age if ecowas==1, absorb(country)
est store m1

areg dem_promotion ///
			african_union ///
			full_economic ///
			democracy_bestmodel ///
			education ///
			gender age if ecowas==1, absorb(country)
est store m2

areg dem_promotion ///
			regional_security ///
			full_economic ///
			democracy_bestmodel ///
			education ///
			gender age if sadc==1, absorb(country)
est store m3	

areg dem_promotion ///
			african_union ///
			full_economic ///
			democracy_bestmodel ///
			education ///
			gender age if sadc==1, absorb(country)
est store m4	
	

areg dem_promotion ///
			regional_security ///
			full_economic ///
			democracy_bestmodel ///
			education ///
			gender age if eac==1, absorb(country)
est store m5
	

areg dem_promotion ///
			african_union ///
			full_economic ///
			democracy_bestmodel ///
			education ///
			gender age if eac==1, absorb (country)
est store m6

	
	
areg dem_promotion ///
			regional_security ///
			full_economic ///
			democracy_bestmodel ///
			education ///
			gender age if uma==1, absorb(country)
est store m7


areg dem_promotion ///
			african_union ///
			full_economic ///
			democracy_bestmodel ///
			education ///
			gender age if uma==1, absorb(country)
est store m8

areg dem_promotion ///
			regional_security ///
			full_economic ///
			democracy_bestmodel ///
			education ///
			gender age if other==1, absorb(country)
est store m9


areg dem_promotion ///
			african_union ///
			full_economic ///
			democracy_bestmodel ///
			education ///
			gender age if other==1, absorb(country)
est store m10


areg dem_promotion ///
			regional_security ///
			democracy_bestmodel ///
			full_economic ///
			education ///
			gender age, absorb(country)
est store m11

outreg2 [m1 m3 m5 m7 m9] using regression_table2.doc, ///
               replace keep(regional_security african_union ///
			full_economic ///
			democracy_bestmodel ///
			education gender age) label dec(3) ///
			title(Table 2: Public Support for Democracy Promotion by Regional Organization) 
			
			   
**Figure 2**			   
coefplot (m1, label("ECOWAS")) ///
         (m3, label("SADC")) ///
         (m5, label("EAC")) ///
         (m7, label("UMA")) ///
		 (m9, label("Other")) ///
		 (m11, label("All Countries")), keep(regional_security ///
			full_economic ///
			democracy_bestmodel ///
			education) ///
			bycoefs xline(0) drop(_cons) ///
	ylabel(, noticks nogrid angle(horizontal) valuelabel) ///
    yscale(off) ytitle("") ///
	bylabel() legend(rows(1))

	
	
*******************************************************
****************Supplementary Material*****************
*******************************************************
**Table A2 Summary Statistics		
estpost tabstat dem_promotion ///
			regional_security african_union ///
			democracy_bestmodel full_economic /// 
			dem_promotion_binary education ///
			gender age one_army_rule ///
			one_party_rule one_man_rule ///
			preference_elect press_freedom ///
			national_identity ///
			pre_elections, statistics(mean sd min max) columns(statistics)
esttab using "summary_stats.rtf", cells("mean(fmt(2)) sd(fmt(2)) min(fmt(0)) max(fmt(0))") noobs replace

	
		
**Table A3: Public Support for Democracy Promotion: AU and Other Countries by Region**		
**note: before running the code for Table A3 run again the code for the regression models for Table 2.

outreg2 [m2 m4 m6 m8 m10] using regression_tableA3.doc, ///
               replace keep(regional_security african_union ///
			full_economic ///
			democracy_bestmodel ///
			education gender age) label dec(3) ///
			   title(Table A3: Public Support for Democracy Promotion: AU and Other Countries by Region) 


		
	
**Table A4: Elections within 12 months of the Data Collection**

areg dem_promotion ///
			regional_security ///
			democracy_bestmodel ///
			full_economic ///
			education ///
			gender age if pre_elections==1, absorb(country)
est store m1

areg dem_promotion ///
			regional_security ///
			democracy_bestmodel ///
			full_economic ///
			education ///
			gender age if pre_elections==0, absorb(country)
est store m2

		
areg dem_promotion ///
			african_union ///
			democracy_bestmodel ///
			full_economic ///
			education ///
			gender age if pre_elections==1, absorb(country)
est store m3

		
areg dem_promotion ///
			african_union ///
			democracy_bestmodel ///
			full_economic ///
			education ///
			gender age if pre_elections==0, absorb(country)
est store m4



outreg2 [m1 m2 m3 m4] using regression_table5.doc, ///
               replace keep(regional_security african_union democracy_bestmodel full_economic education gender age) label dec(3) ///
			   title(Table A4: Elections within 12 months of the Data Collection) ///
			   addnote("Multivariate Regression OLS Coefficients with Country Fixed Effects")
	

	




**Table A6: Public Support for Military Rule**


areg dem_promotion ///
			regional_security ///
			democracy_bestmodel ///
			full_economic ///
			education ///
			gender age one_army_rule, absorb(country)
est store m1
		
areg dem_promotion ///
			african_union ///
			democracy_bestmodel ///
			full_economic ///
			education ///
			gender age one_army_rule, absorb(country)
est store m2

outreg2 [m1 m2] using regression_table6.doc, ///
               replace keep(regional_security african_union democracy_bestmodel full_economic education gender age one_army_rule) label dec(3) ///
			   title(Table A6: Public Support for Military Rule) ///
			   addnote("Multivariate Regression OLS Coefficients with Country Fixed Effects")
	


**Table A7: Public Support for One Party Rule**

areg dem_promotion ///
			regional_security ///
			democracy_bestmodel ///
			full_economic ///
			education ///
			gender age one_party_rule, absorb(country)
est store m1
		
areg dem_promotion ///
			african_union ///
			democracy_bestmodel ///
			full_economic ///
			education ///
			gender age one_party_rule, absorb(country)
est store m2

outreg2 [m1 m2] using regression_table7.doc, ///
               replace keep(regional_security african_union democracy_bestmodel full_economic education gender age one_party_rule) label dec(3) ///
			   title(Table A7: Public Support for One Party Rule) ///
			   addnote("Multivariate Regression OLS Coefficients with Country Fixed Effects")
	
	


**Table A8: Public Support for One Man Rule**

areg dem_promotion ///
			regional_security ///
			democracy_bestmodel ///
			full_economic ///
			education ///
			gender age one_man_rule, absorb(country)
est store m1
		
areg dem_promotion ///
			african_union ///
			democracy_bestmodel ///
			full_economic ///
			education ///
			gender age one_man_rule, absorb(country)
est store m2

outreg2 [m1 m2] using regression_table8.doc, ///
               replace keep(regional_security african_union democracy_bestmodel full_economic education gender age one_man_rule) label dec(3) ///
			   title(Table A8: Public Support for One Man Rule) ///
			   addnote("Multivariate Regression OLS Coefficients with Country Fixed Effects")
	
	


**Table A9: Public Preference for Multiparty Elections**

areg dem_promotion ///
			regional_security ///
			democracy_bestmodel ///
			full_economic ///
			education ///
			gender age preference_elect, absorb(country)
est store m1
		
areg dem_promotion ///
			african_union ///
			democracy_bestmodel ///
			full_economic ///
			education ///
			gender age preference_elect, absorb(country)
est store m2

outreg2 [m1 m2] using regression_table9.doc, ///
               replace keep(regional_security african_union democracy_bestmodel full_economic education gender age preference_elect) label dec(3) ///
			   title(Table A9: Public Preference for Multiparty Elections) ///
			   addnote("Multivariate Regression OLS Coefficients with Country Fixed Effects")
	
	
	
**Table A10: Public Support for Media Freedom**

areg dem_promotion ///
			regional_security ///
			democracy_bestmodel ///
			full_economic ///
			education ///
			gender age press_freedom, absorb(country)
est store m1
		
areg dem_promotion ///
			african_union ///
			democracy_bestmodel ///
			full_economic ///
			education ///
			gender age press_freedom, absorb(country)
est store m2

outreg2 [m1 m2] using regression_table10.doc, ///
               replace keep(regional_security african_union democracy_bestmodel full_economic education gender age press_freedom) label dec(3) ///
			   title(Table A10: Public Support for Media Freedom) ///
			   addnote("Multivariate Regression OLS Coefficients with Country Fixed Effects")
	


**Table A11: The Strength of National Identity and Democracy Promotion**

areg dem_promotion ///
			regional_security ///
			democracy_bestmodel ///
			full_economic ///
			education ///
			gender age national_identity, absorb(country)
est store m1
		
areg dem_promotion ///
			african_union ///
			democracy_bestmodel ///
			full_economic ///
			education ///
			gender age national_identity, absorb(country)
est store m2


outreg2 [m1 m2] using regression_table10.doc, ///
               replace keep(regional_security african_union democracy_bestmodel full_economic education gender age national_identity) label dec(3) ///
			   title(Table A11: The Strength of National Identity and Democracy Promotion) ///
			   addnote("Multivariate Regression OLS Coefficients with Country Fixed Effects")
	
			
**End of the Code File**


			
			
			
			
			

